<template>
  <!-- element Container 布局容器组件 -->
  <el-aside :width="store.state.isCollapsed ? '64px' : '240px'">
    <!-- element Menu菜单组件 -->
    <el-menu
      :collapse="store.state.isCollapsed"
      :collapse-transition="false"
      :router="true"
      :default-active="route.fullPath"
    >
      <el-menu-item index="/index">
        <el-icon>
          <HomeFilled />
        </el-icon>
        <span>首页</span>
      </el-menu-item>
      <el-menu-item index="/center">
        <el-icon>
          <Avatar />
        </el-icon>
        <span>个人中心</span>
      </el-menu-item>
      <el-sub-menu index="/user-manage">
        <template #title>
          <el-icon>
            <UserFilled />
          </el-icon>
          <span>用户管理</span>
        </template>
        <el-menu-item index="/user-manage/useradd">添加用户</el-menu-item>
        <el-menu-item index="/user-manage/userlist">用户管理</el-menu-item>
      </el-sub-menu>
      <el-sub-menu index="/news-manage">
        <template #title>
          <el-icon>
            <MessageBox />
          </el-icon>
          <span>新闻管理</span>
        </template>
        <el-menu-item index="/news-manage/newsadd">添加新闻</el-menu-item>
        <el-menu-item index="/news-manage/newslist">新闻列表</el-menu-item>
      </el-sub-menu>
      <el-sub-menu index="/product-manage">
        <template #title>
          <el-icon>
            <Reading />
          </el-icon>
          <span>产品管理</span>
        </template>
        <el-menu-item index="/product-manage/productadd">添加产品</el-menu-item>
        <el-menu-item index="/product-manage/productlist"
          >产品列表</el-menu-item
        >
      </el-sub-menu>
    </el-menu>
  </el-aside>
</template>

<script setup lang="ts">
//导入ele图标
import {
  HomeFilled,
  Avatar,
  UserFilled,
  MessageBox,
  Reading,
} from "@element-plus/icons-vue";
//导入Store
import { useStore } from "vuex";
//导入当前路由信息
import { useRoute } from "vue-router";

//获取 store
const store = useStore();
//获取当前路由信息 赋值给高亮
const route = useRoute();
// console.log('当前路由', route.fullPath)
</script>

<style scoped lang="scss">
.el-aside {
  height: 100vh;

  .el-menu {
    height: 100vh;
  }
}
</style>
